set(HCCL_PACKET_FLAG 1)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_library(hccl_headers INTERFACE)
target_include_directories(hccl_headers INTERFACE
    $<BUILD_INTERFACE:${TOP_DIR}/ace/comop/inc>
    $<BUILD_INTERFACE:${TOP_DIR}/ace/comop/inc/external>
    $<BUILD_INTERFACE:${TOP_DIR}/ace/comop/inc/external/hccl>
    $<BUILD_INTERFACE:${TOP_DIR}/ace/comop/inc/hccl>
    $<INSTALL_INTERFACE:include>
    $<INSTALL_INTERFACE:include/hccl>
    $<INSTALL_INTERFACE:include/hccl/external>
    $<INSTALL_INTERFACE:include/hccl/external/hccl>
)

set(include_list
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/pub_inc
    ${CMAKE_CURRENT_SOURCE_DIR}/pub_inc/inner
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/pub_inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/aiv
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/component/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/mc2_handler
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/legacy
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/legacy/operator
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/task
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/operator
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/operator/registry
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/registry
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_send_receive
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather_v
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_to_all
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter
    ${CMAKE_CURRENT_SOURCE_DIR}/common/health
    ${CMAKE_CURRENT_SOURCE_DIR}/common/debug/profiling/inc

    ${TOP_DIR}/inc
    ${TOP_DIR}/inc/aicpu/tsd
    ${TOP_DIR}/inc/driver
    ${TOP_DIR}/inc/external
    ${TOP_DIR}/inc/aicpu/
    ${TOP_DIR}/inc/aicpu/aicpu_schedule/aicpu_sharder
    ${TOP_DIR}/abl/qos/qosmng
    ${TOP_DIR}/abl/atrace/inc/utrace
    ${TOP_DIR}/abl/msprof/inc

    ${CMAKE_CURRENT_SOURCE_DIR}/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/hdcs
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/hcom/src
    ${CMAKE_CURRENT_SOURCE_DIR}/hcom/src/gradient_segment
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/op_base/src
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl_heterog/common
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl_heterog/heterog_cpu
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl_heterog/rpc
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/executor/component/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/impl/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/cluster_maintenance/health/heartbeat/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/config
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/task
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/hcom
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/one_sided_service/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/zero_copy_memory_agent
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/resource_manager
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/op_base/src/

    ${TOP_DIR}/asl/hss/inc
    ${TOP_DIR}/asl/hss/inc/pub
    ${TOP_DIR}/asl/hss/common/hash_table

    ${TOP_DIR}/metadef
    ${TOP_DIR}/metadef/inc
    ${TOP_DIR}/metadef/inc/common
    ${TOP_DIR}/metadef/inc/external
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/inc/adapter
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/common/
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/common/unique
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/device
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/host
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/heterog
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/onesided
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/notify
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/ping_mesh
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/socket
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/task
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/tbe_vector_reduce
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/aiv_communication
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/typical

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_all_gather
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_all_reduce
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_alltoall
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_alltoallv
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_broadcast
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_reduce
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_reduce_scatter
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_scatter
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/pub_inc
    ${TOP_DIR}/open_source/json/include
)
add_library(hccd  SHARED)

target_include_directories(hccd PRIVATE
    ${include_list}
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/comm_conn
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/comm/inc/inc_all_reduce_deter
    ${TOP_DIR}/inc/aicpu/tsd
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/wrapper/notify/
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/pub_inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/aiv
    ${CMAKE_CURRENT_SOURCE_DIR}/common/debug/profiling/inc
)

target_compile_options(hccd PRIVATE
    -Werror
    -fno-common
    -fno-strict-aliasing
    -pipe
    -O3
    -std=c++14
)

target_compile_definitions(hccd PRIVATE
    HCCD
)

target_link_libraries(hccd PRIVATE
    $<BUILD_INTERFACE:intf_pub_cxx14>
    $<BUILD_INTERFACE:mmpa_headers>
    $<BUILD_INTERFACE:msprof_headers>
    $<BUILD_INTERFACE:slog_headers>
    $<BUILD_INTERFACE:hccl_headers>
    $<BUILD_INTERFACE:runtime_headers>
    $<BUILD_INTERFACE:network_headers>
    $<BUILD_INTERFACE:atrace_headers>
    $<BUILD_INTERFACE:kernel_tiling_headers>
    -Wl,--no-as-needed
    c_sec
    slog
    mmpa
    -Wl,--as-needed
    -lrt
    -ldl
    -lpthread
    ofed_headers
)

add_library(ccl_kernel  SHARED)

target_include_directories(ccl_kernel PRIVATE
    ${include_list}
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/wrapper/notify/
    ${CMAKE_CURRENT_SOURCE_DIR}/ai_cpu_kernel/
    ${CMAKE_CURRENT_SOURCE_DIR}/ai_cpu_kernel/common/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/cluster_maintenance/recovery/operator_retry/
)

target_compile_options(ccl_kernel PRIVATE
    -Werror
    -fno-common
    -fno-strict-aliasing
    -pipe
    -O3
    -std=c++14
)

target_compile_definitions(ccl_kernel PRIVATE
    HCCD
    CCL_KERNEL
    CCL_KERNEL_AICPU
    USE_AICORE_REDUCESUM
    USE_AICORE_GATHERV2
    USE_AICORE_GATHERV2_INFER
)

target_link_options(ccl_kernel PRIVATE
    -s
)

target_link_libraries(ccl_kernel PRIVATE
    $<BUILD_INTERFACE:intf_pub_cxx14>
    $<BUILD_INTERFACE:mmpa_headers>
    $<BUILD_INTERFACE:msprof_headers>
    $<BUILD_INTERFACE:slog_headers>
    $<BUILD_INTERFACE:hccl_headers>
    $<BUILD_INTERFACE:runtime_headers>
    $<BUILD_INTERFACE:network_headers>
    $<BUILD_INTERFACE:atrace_headers>
    $<BUILD_INTERFACE:kernel_tiling_headers>
    -Wl,--no-as-needed
    c_sec
    slog
    aicpu_sharder
    mmpa
    -Wl,--as-needed
    -lrt
    -ldl
    -lpthread
    ofed_headers
)

add_library(hccl_heterog SHARED)
add_subdirectory(framework)
add_subdirectory(framework_exp)
add_subdirectory(adapter/one_sided_service)
add_subdirectory(hccl)
add_subdirectory(hcom)
add_subdirectory(hccd)
add_subdirectory(hccl_heterog)
add_subdirectory(ai_cpu_kernel)
add_subdirectory(hdcs)
add_subdirectory(algorithm)
add_subdirectory(algorithm/alg_research)
add_subdirectory(platform)
add_subdirectory(common)

set(HCCL_OPEN_CODE_ROOT ${TOP_DIR}/ace/comop/hccl/open_source)
file(GLOB_RECURSE algorithm_research_cc "${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/*.cc")
file(GLOB_RECURSE algorithm_open_cc "${HCCL_OPEN_CODE_ROOT}/src/domain/collective_communication/algorithm/*.cc")
file(GLOB_RECURSE common_cc "${HCCL_OPEN_CODE_ROOT}/src/domain/collective_communication/common/*.cc")

set(FRAMEWORK_SRC PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/config.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/json_utils.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/param_check.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/opexecounter/opexecounter.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/config/env_config.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/hccl_whitelist.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_ranktableParser.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_ranktableStandard.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_ranktableConcise.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_ranktableHeterog.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_roletableParser.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_ranktable_partition.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_parse.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_detect.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_exchange_agent.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_exchange_server.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_exchange_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo/topoinfo_exchange_dispatcher.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/task/callback_thread_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/task/hccl_callback_task.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/thread/threads_guard.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/framework/hcom/hcom_common.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/op_base/src/op_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/hccl_comm.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/comm_config.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/hccl_communicator.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/hccl_communicator_attrs.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/resource_manager/transport_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/resource_manager/preempt_port_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/one_sided_service/i_hccl_one_sided_service.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/cluster_maintenance/health/heartbeat/heartbeat.cc
)

target_sources(hccd PRIVATE
    ${algorithm_open_cc}
    ${algorithm_research_cc}
    ${FRAMEWORK_SRC}
    ${common_cc}
)

target_sources(ccl_kernel PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_alg_utils.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/hccl_alg.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/topo_matcher.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_alg_utils.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/ccl_buffer_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/stream_active_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/workspace_mem.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/workspace_resource.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/workspace_resource_impl.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/op_base_stream_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/offload_stream_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/hccl_socket_manager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager/queue_notify_manager.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy/comm_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy/comm_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy/comm_p2p.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy/comm_mesh.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy/comm_halving_doubling.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy/comm_star.cc
    #${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/comm_partial_mesh.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/calc_hd_transport_req.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/calc_mesh_transport_req.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/calc_partial_mesh_transport_req.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/calc_ring_transport_req.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/calc_transport_req_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/calc_p2p_transport_req.cc


    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/aligned_reduce_scatter_double_ring_with_serial_local_copy.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/aligned_reduce_scatter_double_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/aligned_all_gather_double_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_ring_concurrent_direct.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_ring_concurrent_direct.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_scatter/scatter_ring_concurrent_direct.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_scatter/scatter_double_ring_direct.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_halving_doubling.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_mesh.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_mesh_direct.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_mesh_atomic.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_mesh_mix.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_reduce/all_reduce_recursive_hd.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_reduce/all_reduce_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_broadcast/bcast_halvingdoubling.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_broadcast/bcast_recursive_halvingdoubling.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_broadcast/broadcast_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_broadcast/broadcast_star.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/alg_template_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/recursive_halvingdoubling_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce/reduce_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_halving_doubling.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_recursive_hd.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_mesh.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_mesh_atomic.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_mesh_mix.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_mesh_mix_single_stream.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_scatter/scatter_mesh.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_scatter/scatter_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_scatter/multi_root_scatter_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_send_recv/send_receive.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_all_gather/all_gather_recursive_hd.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_gather/gather_ring.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_gather/gather_mesh.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_gather/gather_star.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce/reduce_recursive_hd.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_alltoallv/alltoallv_pairwise.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_alltoallv/alltoallv_staged_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_alltoallv/alltoallv_staged_pairwise.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_alltoallv/alltoallv_staged_mesh.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_alltoallv/alltoallv_staged_calculator.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_alltoallv/alltoallv_mesh_read_only.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/temp_reduce_scatter/reduce_scatter_mesh_atomic_opbase.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_alltoallv/alltoallv_for_310p.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/alg_template/temp_alltoallv/alltoallv_direct_fullmesh.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/mc2_handler/mc2_handler.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_executor_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_native_executor_base.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_comm_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_single_rank_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_fast_double_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_aligned_all_reduce_double_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_comm_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_double_ring_concurrent_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_mesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_mesh_mid_count_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_mesh_oneshot_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_mesh_opbase_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_mesh_opbase_pipeline_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_mesh_small_count_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_reduce_plus_bcast_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/coll_all_reduce_mix_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/310P/coll_all_reduce_for_310p_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/310P/coll_all_reduce_for_310p_doubling_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/310P/coll_all_reduce_for_310p_doubling_direct_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_comm_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_aligned_all_gather_double_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_mesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_mesh_opbase_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_mesh_opbase_pipeline_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_single_rank_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_double_ring_concurrent_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_small_count_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_semi_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/coll_all_gather_mix_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather_v/coll_all_gather_v_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/coll_broadcast_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/coll_broadcast_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/coll_broadcast_mesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/coll_broadcast_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/coll_broadcast_comm_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/coll_broadcast_smallcount_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/coll_broadcast_mix_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce/coll_reduce_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce/coll_reduce_mesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce/coll_reduce_ring_plus_hd_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce/coll_reduce_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce/coll_reduce_comm_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce/coll_reduce_single_rank_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_comm_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_deter_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_fast_double_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_aligned_reduce_scatter_double_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_mesh_dma_elimination.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_mesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_mesh_opbase_pipeline_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_single_rank_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_double_ring_concurrent_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_semi_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/coll_reduce_scatter_mix_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v/coll_reduce_scatter_v_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v/coll_reduce_scatter_v_aiv_big_count_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v/coll_reduce_scatter_v_mesh_aiv_smallcount_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v/coll_reduce_scatter_v_mesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v/coll_reduce_scatter_v_mesh_opbase_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter/coll_scatter_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter/coll_scatter_ring_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter/coll_scatter_ring_for_910_93_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter/coll_scatter_comm_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter/coll_scatter_mesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter/coll_scatter_single_rank_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_send_receive/coll_batch_send_recv_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_send_receive/coll_batch_send_recv_retry_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_send_receive/coll_send_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_send_receive/coll_receive_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_to_all/coll_all_to_all_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_to_all/coll_all_to_all_single_rank_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_to_all/coll_all_to_all_v_fullmesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_to_all/coll_all_to_all_v_direct_fullmesh_executor.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_to_all/310P/coll_all_to_all_v_for_310p_executor.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/registry/coll_alg_exec_registry.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/alg_profiling.cc

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/task/threadManage.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/task/parallel_task_loader.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/task/task_loader.cc

    ${FRAMEWORK_SRC}
    ${common_cc}
)

install(TARGETS  hccd
    LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}  OPTIONAL
)

install(TARGETS  ccl_kernel
    LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}  OPTIONAL
)

target_compile_definitions(hccl_heterog  PRIVATE
    USE_AICORE_REDUCESUM
    USE_AICORE_GATHERV2
    USE_AICORE_GATHERV2_INFER
)

target_compile_options(hccl_heterog PRIVATE
    -Werror
    -fno-common
    -fno-strict-aliasing
    -pipe
    -O3
    -std=c++14
    -fstack-protector-all
)

target_link_options(hccl_heterog PRIVATE
    -Wl,-z,relro
    -Wl,-z,now
    -Wl,-z,noexecstack
)

#头文件搜索路径
target_include_directories(hccl_heterog PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/pub_inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/aiv
    ${CMAKE_CURRENT_SOURCE_DIR}/pub_inc
    ${CMAKE_CURRENT_SOURCE_DIR}/pub_inc/inner
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/mc2_handler
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/alg_template/component/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/legacy
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/legacy/operator
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/base/communicator/legacy

    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/resource_manager
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/task
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/operator
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/operator/registry
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/registry
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_send_receive
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_reduce/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_to_all
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_all_gather_v
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_reduce_scatter_v
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_scatter
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/impl/coll_executor/coll_broadcast/310P
    ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/alg_research/pub_inc

    ${CMAKE_CURRENT_SOURCE_DIR}/common/health
    ${CMAKE_CURRENT_SOURCE_DIR}/common/debug/profiling/inc

    ${CMAKE_CURRENT_SOURCE_DIR}/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/cluster_maintenance/health/heartbeat/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/cluster_maintenance/recovery/operator_retry/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/config
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/task
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/topo
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/common/src/exception
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/one_sided_service/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/zero_copy_memory_agent/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/communicator/impl/resource_manager/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/hcom/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/inc/
    ${CMAKE_CURRENT_SOURCE_DIR}/framework/op_base/src

    ${CMAKE_CURRENT_SOURCE_DIR}/framework_exp/one_sided_service
    ${CMAKE_CURRENT_SOURCE_DIR}/framework_exp/common/buffer_manager

    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/impl/resource_manager

    ${TOP_DIR}/open_source/json/include
    ${TOP_DIR}/inc
    ${TOP_DIR}/inc/driver
    ${TOP_DIR}/inc/external
    ${TOP_DIR}/inc/aicpu/
    ${TOP_DIR}/metadef/inc/common/util/error_manager
    ${CMAKE_CURRENT_SOURCE_DIR}/framework

    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/executor/component/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/wrapper/notify
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl/hccl_comm/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/hcom/src
    ${CMAKE_CURRENT_SOURCE_DIR}/hcom/src/gradient_segment
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl_heterog/heterog_cpu
    ${CMAKE_CURRENT_SOURCE_DIR}/hccl_heterog/common

    ${CMAKE_CURRENT_SOURCE_DIR}/platform/
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/inc/adapter
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/common
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/common/unique
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/socket
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/device
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/host
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/heterog
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/transport/onesided
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/notify
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/ping_mesh
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/task
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/tbe_vector_reduce

    ${CMAKE_CURRENT_SOURCE_DIR}/platform/resource/rma_buffer

    ${TOP_DIR}/ace/comop/inc/external/hccl/
    ${TOP_DIR}/ace/comop/inc/hccl/
    ${TOP_DIR}/abl/msprof/inc
    ${TOP_DIR}/abl/qos/qosmng
    ${TOP_DIR}/abl/atrace/inc/utrace
    ${TOP_DIR}/ace/npuruntime/inc
    ${TOP_DIR}/ace/npuruntime/external
    ${TOP_DIR}/asl/hss/common/hash_table
    ${TOP_DIR}/asl/hss/inc/
    ${TOP_DIR}/asl/hss/inc/pub
    ${TOP_DIR}/metadef/inc
    ${TOP_DIR}/metadef/inc/external
    ${TOP_DIR}/inc/aicpu/aicpu_schedule/aicpu_sharder
)

target_link_libraries(hccl_heterog
        PRIVATE
        $<BUILD_INTERFACE:intf_pub_cxx14>
        $<BUILD_INTERFACE:mmpa_headers>
        $<BUILD_INTERFACE:msprof_headers>
        $<BUILD_INTERFACE:slog_headers>
        $<BUILD_INTERFACE:hccl_headers>
        $<BUILD_INTERFACE:runtime_headers>
        $<BUILD_INTERFACE:cce_headers>
        $<BUILD_INTERFACE:network_headers>
        $<BUILD_INTERFACE:atrace_headers>
        $<BUILD_INTERFACE:kernel_tiling_headers>
        -Wl,--no-as-needed
        c_sec
        mmpa
        runtime
        qos_manager
        error_manager
        exe_graph
        lowering
        hccl
        -Wl,--as-needed
        -lrt
        -ldl
        -lpthread
        ofed_headers
        PUBLIC
        hccl_headers
)

install(TARGETS  hccl_heterog
    LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}  OPTIONAL
)

install_package(
    PACKAGE hccl
    TARGETS hccl hccl_heterog hccl_headers
    FILES   ${TOP_DIR}/ace/comop/hccl/open_source/inc/hccl/hccl.h
            ${TOP_DIR}/ace/comop/hccl/open_source/inc/hccl/hccl_types.h
            ${TOP_DIR}/ace/comop/hccl/whole/hccl/pub_inc/hccn_rping.h
    DESTINATION ${INSTALL_INCLUDE_DIR}/hccl/external/hccl
    FILES   ${TOP_DIR}/ace/comop/inc/hccl/base.h
            ${TOP_DIR}/ace/comop/inc/hccl/hcom.h
            ${TOP_DIR}/ace/comop/inc/hccl/hcom_executor.h
    DESTINATION ${INSTALL_INCLUDE_DIR}/hccl
)
